<template>
  <el-form label-width="100px" class="container">
    <el-form-item label="邮箱">
      <el-input
        type="email"
        v-model="email"
        placeholder="请输入 Email..."
      ></el-input>
    </el-form-item>
    <el-form-item>
      <el-button
        type="primary"
        @click="handleForgotPassword()"
        class="submit-btn"
        >找回密码
      </el-button>
    </el-form-item>
  </el-form>
</template>

<script lang="ts">
import { ref, getCurrentInstance } from "vue";

export default {
  name: "ForgotPassword",

  setup() {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    const { ctx } = getCurrentInstance();

    const email = ref<string>("");

    const handleForgotPassword = async () => {
      if (email.value) {
        // eslint-disable-next-line @typescript-eslint/no-unused-vars
        const res = await ctx.$axios.post("/api/v1/auth/forgotpassword", {
          email: email.value,
        });
      }
    };

    return { email, handleForgotPassword };
  },
};
</script>

<style scoped>
.container {
  margin: 100px auto 0 auto;
  width: 800px;
}
.submit-btn {
  width: 100%;
}
</style>
